All files / src/app/api/photo-files/[photoId] route.ts

85.71% Statements 6/7
75% Branches 3/4
100% Functions 1/1
85.71% Lines 6/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24        1x           1x 1x 1x   1x       1x          
import { NextResponse, type NextRequest } from "next/server";
import { serveItemPhotoFile } from "@/server/api/item-photo-file";
 
// sharp (used by servePhotoFile) is a native addon — pin the Node runtime.
export const runtime = "nodejs";
 
export async function GET(
  request: NextRequest,
  { params }: { params: Promise<{ photoId: string }> },
) {
  const { photoId } = await params;
  const collectionId = request.nextUrl.searchParams.get("collectionId");
  const itemId = request.nextUrl.searchParams.get("itemId");
 
  Iif (!collectionId || !itemId) {
    return NextResponse.json({ error: "Missing photo scope" }, { status: 400 });
  }
 
  return serveItemPhotoFile(
    request,
    Promise.resolve({ id: collectionId, itemId, photoId }),
  );
}